package com.kangye.enterprise.frontdesk.service.impl;

import com.kangye.enterprise.frontdesk.entity.Attention;
import com.kangye.enterprise.frontdesk.entity.Item;
import com.kangye.enterprise.frontdesk.mapper.AttentionMapper;
import com.kangye.enterprise.frontdesk.service.AttentionService;
import com.kangye.enterprise.frontdesk.util.ViewJsonObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: enterprise
 * @description: 实现逻辑接口类
 * @author: 索腾龙
 * @create: 2021-05-31 14:09
 **/
@Service
@Transactional
public class AttentionServiceImpl implements AttentionService {
    @Autowired
    private AttentionMapper attentionMapper;
    //政策即时推送(未关注) 选择部门关注  点击确定(索腾龙写)
    @Override
    public Integer addAttention(List<Attention> list) {
        return attentionMapper.addAttention(list);
    }
    //查询用户关注的信息(索腾龙写)
    @Override
    public ViewJsonObject<Attention> selAttention(Integer attentionUsersid) {
        List<Attention> list = attentionMapper.selAttention(attentionUsersid);
        //判断list里是否有数据
        if (list.size()>0) {
            //返回json格式
            return new ViewJsonObject<Attention>(list);
        } else {
            return new ViewJsonObject<>(1, "操作失败");
        }
    }
    //点击取消关注 删除这条消息(索腾龙写)
    @Override
    public Integer delAttention(Integer attentionId){
        return attentionMapper.delAttention(attentionId);
    }
}